<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        div {
            text-align: center;
            font-size: 30px;
        }

        #click_login {
            cursor: pointer;
        }

        #login {
            display: none;
            position: absolute;
            left: 50%;
            top: 100px;
            margin-left: -250px;
            overflow: hidden;
            width: 500px;
            height: 350px;
            background: #f1f1f1;
            /* margin: 100px auto; */
            text-align: center;
        }

        #login div {
            cursor: move;
            padding: 10px 0 0 0;
        }

        #login p {
            margin: 50px 0 0 0;
            overflow: hidden;
        }

        #login p span {
            float: left;
            font-size: 16px;
            margin: 10px 10px 0 50px;
        }

        #login p input {
            float: left;
            width: 300px;
            height: 40px;
            line-height: 40px;
            border: 1px solid #000;
            outline: none;
            text-indent: 1em;
            font-size: 16px;
        }

        #login span {
            display: block;
            font-size: 30px;
            margin: 10px 0 0 0;
        }

        #login aside {
            position: absolute;
            right: 10px;
            top: 10px;
            width: 25px;
            height: 22px;
            background-image: url(image/X.jpg);
            font-size: 20px;
            cursor: pointer;
        }

        #login input[type="button"] {
            width: 300px;
            height: 40px;
            text-align: center;
            line-height: 40px;
            color: #fff;
            background-color: skyblue;
            margin-top: 20px;
            border: none;
            z-index: 2;
            cursor: pointer;
        }

        .current {
            background-color: #33333330;
        }

        #all {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 800px;
            z-index: -1;
        }
    </style>
    <script src="js/common.js">
    </script>
</head>

<body>
    <div>
        <span id="click_login">点击登录</span>
    </div>
    <div id="login">
        <aside></aside>
        <div>
            <span>登录</span>
        </div>

        <p>
            <span>账号 :</span>
            <input type="text">
        </p>
        <p>
            <span>密码 : </span>
            <input type="password">
        </p>
        <input type="button" value="登录" id="btn">

    </div>
    <div class="current" id="all">
    </div>
    <script>
        var click_login = document.querySelector("#click_login");
        var all = document.querySelector('#all');
        var login = document.querySelector("#login");
        var aside = document.querySelector('aside');
        var odiv = login.querySelector('div');
        //点击按钮，弹出登录框
        click_login.onclick = function () {
            login.style.display = "block";
            all.style.display = "block";
        }
        //点击X号关闭登录框
        aside.onclick = function () {
            login.style.display = "none";
            all.style.display = "none";
        }
        // 鼠标点在odiv上拖拽对话框移动
        odiv.onmousedown = function (e) {
            var flag = true;
            var left = parseInt(getStyle(login, "left"));
            var top = parseInt(getStyle(login, "top"));
            var num = evt.getPageX(e) - left;
            var num1 = evt.getPageY(e) - top;
            document.onmousemove = function (e) {
                if (flag) {

                    login.style.left = evt.getPageX(e) - num + "px";
                    login.style.top = evt.getPageY(e) - num1 + "px";

                }
            }
            document.onmouseup = function () {
                flag = false;
            }
        }
    </script>
</body>

</html>